<?php 
require_once 'classes/Resource.php';
include('includes/confirm.php');

$resource = New Resources();
$page_name = media;
$mysql = new Mysql();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <?php include('includes/head.php'); ?>
<body>
<div id="wrapper">
    <?php include('includes/header.php'); ?>
    <?php include('includes/menu.php'); ?>
    
  <div id="page">
	
	<?php print $responce; 
		$responce = "Copy already requested to be borrowed!";
		if($_POST && $_POST['c_id']){
				$stmt=$mysql->run_query("SELECT id FROM borrow 
																	WHERE copy_id=? 
																		AND user_id=?
																		AND status=?", $_POST['c_id'], $_SESSION['userid'], "0");
				$stmt->bind_result($id);
				if(!$stmt->fetch()){
					$mysql->run_query_string("INSERT INTO borrow (copy_id,user_id,status) VALUES ('".$_POST['c_id']."','".$_SESSION['userid']."','0')");
					$responce = "Copy Requested to be borrowed";
			}
		}
		echo "<h3>$responce</h3><br><br>";
	?>
     
	
  </div>
  <!-- end div#page -->
    <?php include('includes/footer.php'); ?>
</div> <!-- end div#wrapper -->
</body>
</html>

